library(ggplot2)
data("mtcars")
print(mtcars)
mtcars$gear <- factor(mtcars$gear, levels = c(3,4,5), labels = c("3_gears", "4_gears", "5_gears"))
mtcars$am <- factor(mtcars$am, levels = c(0,1), labels = c("automatic", "manuals"))
mtcars$cyl <- factor(mtcars$cyl, levels = c(4,6,8), labels = c("4cyl", "6cyl", "8cyl"))
ggplot(data = mtcars, mapping = aes(x = wt, y = mpg)) + geom_point()

ggplot(data = mtcars, mapping = aes(x = wt, y = mpg, color = as.factor(cyl))) + geom_point()

ggplot(data = mtcars, mapping = aes(x = wt, y = mpg, size = qsec)) + geom_point()

p <- ggplot(data = mtcars, mapping = aes(x = wt, y = mpg, shape = factor(cyl)))
p + geom_point(
aes(color = factor(cyl)), size = 4
) + geom_point(colour = "grey90", size = 1.5)

library(plotly)
Attaching package: ‘plotly’
The following object is masked from ‘package:ggplot2’:
last_plot
The following object is masked from ‘package:stats’:
filter
The following object is masked from ‘package:graphics’:
layout
p <- plot_ly(data = mtcars, x = ~hp, y = ~wt)
p
No trace type specified:
Based on info supplied, a 'scatter' trace seems appropriate.
Read more about this trace type -> https://plot.ly/r/reference/#scatter
No scatter mode specifed:
Setting the mode to markers
Read more about this attribute -> https://plot.ly/r/reference/#scatter-mode
No trace type specified:
Based on info supplied, a 'scatter' trace seems appropriate.
Read more about this trace type -> https://plot.ly/r/reference/#scatter
No scatter mode specifed:
Setting the mode to markers
Read more about this attribute -> https://plot.ly/r/reference/#scatter-mode
p <- plot_ly(
data = mtcars, x = ~hp, y = ~wt,
marker = list(
size = 10, color = "rgba(255, 182, 193, .9)",
line = list(
color = "rgba(152, 0, 0, .8)", width = 2
)
)
)
p
No trace type specified:
Based on info supplied, a 'scatter' trace seems appropriate.
Read more about this trace type -> https://plot.ly/r/reference/#scatter
No scatter mode specifed:
Setting the mode to markers
Read more about this attribute -> https://plot.ly/r/reference/#scatter-mode
No trace type specified:
Based on info supplied, a 'scatter' trace seems appropriate.
Read more about this trace type -> https://plot.ly/r/reference/#scatter
No scatter mode specifed:
Setting the mode to markers
Read more about this attribute -> https://plot.ly/r/reference/#scatter-mode
st_data <- rnorm(100, mean = 10)
nd_data <- rnorm(100, mean = 0)
thrd_data <- rnorm(100, mean = -10)
xth_index <- c(1:100)
data_beta <- data.frame(xth_index, st_data, nd_data, thrd_data)
p <- plot_ly(data_beta, x = ~xth_index)%>%
add_trace(y = ~st_data, name = "data1", mode = "lines")%>%
add_trace(y = ~nd_data, name = "data2", mode = "lines+markers")%>%
add_trace(y = ~thrd_data, name = "data3", mode = "markers")
p
No trace type specified:
Based on info supplied, a 'scatter' trace seems appropriate.
Read more about this trace type -> https://plot.ly/r/reference/#scatter
No trace type specified:
Based on info supplied, a 'scatter' trace seems appropriate.
Read more about this trace type -> https://plot.ly/r/reference/#scatter
No trace type specified:
Based on info supplied, a 'scatter' trace seems appropriate.
Read more about this trace type -> https://plot.ly/r/reference/#scatter
No trace type specified:
Based on info supplied, a 'scatter' trace seems appropriate.
Read more about this trace type -> https://plot.ly/r/reference/#scatter
No trace type specified:
Based on info supplied, a 'scatter' trace seems appropriate.
Read more about this trace type -> https://plot.ly/r/reference/#scatter
No trace type specified:
Based on info supplied, a 'scatter' trace seems appropriate.
Read more about this trace type -> https://plot.ly/r/reference/#scatter
p <- plot_ly(data = mtcars, x = ~hp, y = ~wt, color = ~hp, size = ~hp)
p
No trace type specified:
Based on info supplied, a 'scatter' trace seems appropriate.
Read more about this trace type -> https://plot.ly/r/reference/#scatter
No scatter mode specifed:
Setting the mode to markers
Read more about this attribute -> https://plot.ly/r/reference/#scatter-mode
`line.width` does not currently support multiple values.No trace type specified:
Based on info supplied, a 'scatter' trace seems appropriate.
Read more about this trace type -> https://plot.ly/r/reference/#scatter
No scatter mode specifed:
Setting the mode to markers
Read more about this attribute -> https://plot.ly/r/reference/#scatter-mode
`line.width` does not currently support multiple values.
LS0tCnRpdGxlOiAiUiBOb3RlYm9vayIKb3V0cHV0OiBodG1sX25vdGVib29rCi0tLQoKYGBge3J9Cmxp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